package com.nit.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 操作系统
 */
@Getter
public enum OSEnum {
    WIN("win"),
    LINUX("linux"),
    MAC("mac"),
    UNKNOWN("unknown");

    public String name;

    OSEnum(String name) {
        this.name = name;
    }

    public static OSEnum getOSEnum() {
        return Arrays.stream(OSEnum.values()).filter(a -> osName.contains(a.getName())).findAny().orElse(OSEnum.UNKNOWN);
    }

    static String osName = "";

    static {
        osName = System.getProperty("os.name").toLowerCase();
    }
}
